<?php

namespace Gnway\Ticket\Rest\Response;

use Gnway\Ticket\Rest\Contracts\HttpResponseInterface;

class ResponseFactory
{

  /**
   * @var array|string[]
   */
  private static array $defaultJsonHeaders = ['Content-Type: application/json; charset=UTF-8'];

  /**
   * @var array|string[]
   */
  private static array $defaultTextPlainHeaders = ['Content-Type: text/plain; charset=UTF-8'];

  /**
   * Response Json
   *
   * @param array $value
   * @param array $headers
   * @param int   $code
   * @return HttpResponseInterface
   */
  public static function json(array $value, array $headers = [], int $code = 200): HttpResponseInterface
  {
    $headers || $headers = self::$defaultJsonHeaders;

    return new HttpResponseJson($value, $headers, $code);
  }

  /**
   * Response String
   *
   * @param string $value
   * @param array  $headers
   * @param int    $code
   * @return HttpResponseInterface
   */
  public static function text(string $value, array $headers = [], int $code = 200): HttpResponseInterface
  {
    $headers || $headers = self::$defaultTextPlainHeaders;

    return new HttpResponseText($value, $headers, $code);
  }
}